package com.treasure.service.commonutil;

import java.util.List;
import java.util.Objects;
import java.util.function.BiConsumer;

/**
* @Description:    java类作用描述
* @Author:         panxinwen
* @CreateDate:     2018/12/16 17:34
* @Version:        1.0
*/
public class Iterables {
    public static <E> void forEach(List<? extends E> elements, BiConsumer<Integer, ? super E> action) {
        Objects.requireNonNull(elements);
        Objects.requireNonNull(action);

        int index = 0;
        for (E element : elements) {
            action.accept(index++, element);
        }
    }

}
